
package pos.entity;


import java.sql.Date;

/**
 * This is the entity class for promotions (sales) 
 * @author Justin Hume
 */
public class Promotion {
    
    // -------------------------------------------------------------------------
    //  Private fields
    // -------------------------------------------------------------------------
    private long promotionId;
    private String promotionName = null;
    private String promotionDescription = null;
    private String promotionConditions = null;
    private int promotionType;
    private double promotionPriceAdjustment = 0;
    private long promotionCreatedByEmployeeId;
    private Date promotionStartDateTime = null;
    private Date promotionEndDateTime = null;
    private Date dateTimeCreated = null;
    private Date dateTimeModified = null;

    /**
     * An enum with the available promotion types
     */
    public enum PromotionType { FLAT, CARD, HOLIDAY, CLEARANCE }

    // -------------------------------------------------------------------------
    //  Properties (get/set methods)
    // -------------------------------------------------------------------------

    //Get the table name represented by this entity
    public static String getTableName(){
        return "PROMOTION";
    }

    //Database generated primary key field (read-only)
    public long getPromotionID(){
        return promotionId;
    }

    //Promotion name
    public void setPromotionName(String promotionName){
        this.promotionName = promotionName;
    }
    
    public String getPromotionName(){
        return promotionName;
    }

    //Promotion description
    public void setPromotionDescription(String promotionDescription){
        this.promotionDescription = promotionDescription;
    }
    
    public String getPromotionDescription(){
        return promotionDescription;
    }

    //promotionConditions
    public void setPromotionConditions(String promotionConditions){
        this.promotionConditions = promotionConditions;
    }

    public String getPromotionConditions(){
        return promotionConditions;
    }

    //promotionType
    public void setPromotionType(PromotionType promoType){
        this.promotionType = promoType.ordinal();
    }

    public PromotionType getPromotionType(){
        return PromotionType.values()[promotionType];
    }

    //promotionPriceAdjustment (Validation rule: must be between 0.01 and 0.99)
    public boolean setPromotionPriceAdjustment(double promoPriceAdjustment){

        //price adjustment is invalid
        if (promoPriceAdjustment < 0.01 ||
            promoPriceAdjustment > 0.99)
        {
            return false;
        }
        //price adjustment is valid
        else
        {
            this.promotionPriceAdjustment = promoPriceAdjustment;
            return true;
        }
    }

    public double getPromotionPriceAdjustment(){
        return promotionPriceAdjustment;
    }

    //promotionCreatedByEmployeeId
    public long getPromotionCreatedByEmployeeId() {
        return promotionCreatedByEmployeeId;
    }

    public void setPromotionCreatedByEmployeeId(long promotionCreatedByEmployeeId) {
        this.promotionCreatedByEmployeeId = promotionCreatedByEmployeeId;
    }

    //promotionStartDateTime
    public Date getPromotionStartDateTime() {
        return promotionStartDateTime;
    }

    public void setPromotionStartDateTime(Date promotionStartDateTime) {
        this.promotionStartDateTime = promotionStartDateTime;
    }

    //promotionEndDateTime
    public Date getPromotionEndDateTime() {
        return promotionEndDateTime;
    }

    public void setPromotionEndDateTime(Date promotionEndDateTime) {
        this.promotionEndDateTime = promotionEndDateTime;
    }

    //DateTimeCreated
    public Date getDateTimeCreated() {
        return dateTimeCreated;
    }

    public void setDateTimeCreated(Date dateTimeCreated) {
        this.dateTimeCreated = dateTimeCreated;
    }

    //DateTimeModified
    public Date getDateTimeModified() {
        return dateTimeModified;
    }

    public void setDateTimeModified(Date dateTimeModified) {
        this.dateTimeModified = dateTimeModified;
    }
    
}
